package com.lainiao.response;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/rd")
public class response01_ResponseData extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        /**
         * getWriter()：字符输出流（输出字符串）
         */
//        // 1. 获取字符输出流
//        PrintWriter writer = response.getWriter();
//        // 2. 向浏览器输出字符串
//        writer.write("ya xi la lei · liang fei fan ！");


        /**
         * getOutputStream()：字节输出流（输出一切数据）
         */
        // 1. 获取字节输出流
        ServletOutputStream stream = response.getOutputStream();
        // 2. 向浏览器输出字节流数据
        stream.write("ni hao !".getBytes());
    }
}
